﻿using MslDiary.Model;
using System;
using System.Collections.Generic;
using System.Windows.Input;

namespace MslDiary.ViewModel
{
    public class EditorListSkinViewModel : MslDiary.Framework.ViewModelBase
    {
        private const string EDITOR_SKIN_PATH = "/Theme/Images/EditorSkin/";
        public EditorListSkinViewModel()
        {
            MslDiary.Framework.Gloable.IsSkinChanged = false;
            this.SkinList = new List<SkinModel>()
            {
                //统一采用 JPG 图片 200 * 200
                new SkinModel(){Path=EDITOR_SKIN_PATH+"default.jpg",Name="默认"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"1.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"2.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"3.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"4.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"5.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"6.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"7.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"8.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"9.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"10.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"11.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"12.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"13.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"14.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"15.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"16.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"17.jpg"},
                new SkinModel(){Path=EDITOR_SKIN_PATH+"18.jpg"}
            };
            this.SelectedSkinIndex = this.SkinList.FindIndex(new Predicate<SkinModel>((p) =>
            {
                return p.Path.Equals(MslDiary.Framework.Gloable.AppBackgroundImage);
            }));

            this.SkinSelectedChangedCommand = new CommandBase((Object mod) =>
            {
                if (mod != null)
                {
                    this.SkinMod = (SkinModel)mod;
                    MslDiary.Framework.Gloable.EditorBackgroundImage = this.SkinMod.Path;
                    MslDiary.Framework.Gloable.IsEditorSkinChanged = true;
                }
            });
        }
        #region 属性

        private int _selectedSkinIndex = 0;
        public SkinModel SkinMod { get; set; }
        public List<SkinModel> SkinList { get; set; }
        public int SelectedSkinIndex
        {
            get { return _selectedSkinIndex; }
            set
            {
                //base.SetProperty<int>(ref this._selectedSkinIndex, value);
                if (this._selectedSkinIndex == value)
                    return;
                this._selectedSkinIndex = value;
                this.RaisePropertyChanged("SelectedSkinIndex");
            }
        }
        #endregion

        #region 命令
        public ICommand SkinSelectedChangedCommand { get; set; }
        #endregion

        #region 方法

        #endregion
    }
}
